package com.situ.springboot.controller;

import com.situ.springboot.annotation.MyLog;
import com.situ.springboot.pojo.Blog;
import com.situ.springboot.pojo.VO.BlogVO;
import com.situ.springboot.pojo.query.BlogQuery;
import com.situ.springboot.service.IBlogService;
import com.situ.springboot.util.PageResult;
import com.situ.springboot.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

//@Controller
@RestController //= @Controller + @ResponseBody
@RequestMapping("/blog")
public class BlogController {

    @Autowired
    private IBlogService blogService;

    @MyLog
    @RequestMapping("/selectByPage")
    public PageResult<BlogVO> selectByPage(BlogQuery blogQuery) {
        return blogService.selectByPage(blogQuery);
    }

    @MyLog
    @RequestMapping("/add")
    public Result add(Blog blog) {
        blogService.add(blog);
        return Result.ok("添加成功");
    }
}
